package com.kun.rental.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kun.rental.entity.CarrentalBrand;
import com.kun.rental.mapper.CarrentalBrandMapper;
import com.kun.rental.service.ICarrentalBrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ikun
 * @since 2024-07-04
 */
@Service
public class CarrentalBrandServiceImpl extends ServiceImpl<CarrentalBrandMapper, CarrentalBrand> implements ICarrentalBrandService {

    @Autowired
    private CarrentalBrandMapper carrentalBrandMapper;
    /**
     * 按照分页条件搜索租车品牌信息。
     *
     * @param page           分页参数，包含当前页码和每页的记录数等信息。
     * @param carrentalBrand 租车品牌条件对象，
     */
    @Override
    public Page<CarrentalBrand> searchByPage(Page<CarrentalBrand> page,
                                             CarrentalBrand carrentalBrand) {
        return baseMapper.searchByPage(page,carrentalBrand);
    }

    /**
     * 根据厂商id查询品牌信息
     * @param makerId
     * @return
     */
    @Override
    public List<CarrentalBrand> selectByMakerId(Integer makerId) {
        QueryWrapper<CarrentalBrand> queryWrapper = new QueryWrapper();
        queryWrapper.eq("mid",makerId);
        return carrentalBrandMapper.selectList(queryWrapper);
    }
}
